/**
 *  iBizSys 5.0 机器人生产代码（不要直接修改当前代码）
 *  http://www.ibizsys.net
 */
package com.sa.ibiz.demo.srv.demo.service;


import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Component;
import net.ibizsys.paas.exception.ErrorException;
import net.ibizsys.paas.core.PluginActionResult;
import net.ibizsys.paas.core.IDataEntity;
import net.ibizsys.paas.core.IDEDataSetFetchContext;
import net.ibizsys.paas.db.DBCallResult;
import net.ibizsys.paas.db.DBFetchResult;
import net.ibizsys.paas.db.IProcParam;
import net.ibizsys.paas.util.StringHelper;
import net.ibizsys.paas.util.StringBuilderEx;
import net.ibizsys.paas.core.Errors;
import net.ibizsys.paas.core.ActionContext;
import net.ibizsys.paas.data.DataObject;
import net.ibizsys.paas.service.ServiceGlobal;
import net.ibizsys.paas.entity.IEntity;
import net.ibizsys.paas.demodel.IDataEntityModel;
import net.ibizsys.paas.demodel.DEModelGlobal;
import net.ibizsys.paas.demodel.IDELogicModel;
import net.ibizsys.paas.dao.DAOGlobal;
import net.ibizsys.paas.web.WebContext;
import net.ibizsys.paas.service.IService;
import net.ibizsys.paas.util.DataTypeHelper;
import net.ibizsys.paas.util.KeyValueHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.ibizsys.paas.db.SelectCond;
import net.ibizsys.paas.service.IServiceWork;
import net.ibizsys.paas.service.IServicePlugin;
import net.ibizsys.paas.service.ITransaction;
import net.ibizsys.paas.dao.IDAO;
import net.ibizsys.paas.service.CloneSession;
import net.ibizsys.paas.service.ServiceBase;
import net.ibizsys.paas.entity.EntityFieldError;
import net.ibizsys.paas.entity.EntityError;
import java.sql.Timestamp;
import net.ibizsys.paas.util.DefaultValueHelper;
import javax.annotation.PostConstruct;
import net.ibizsys.paas.service.IDataContextParam;
import net.sf.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;



import com.sa.ibiz.demo.srv.demo.entity.ProjectMembers;
import com.sa.ibiz.demo.srv.demo.dao.ProjectMembersDAO;
import com.sa.ibiz.demo.srv.demo.demodel.ProjectMembersDEModel;


/**
 * 实体[ProjectMembers] 服务对象基类
 */
@Component
public class ProjectMembersService extends com.sa.ibiz.demo.srv.MyTestSysSysServiceBase<ProjectMembers> {
    private static final Log log = LogFactory.getLog(ProjectMembersService.class);
    /**
     * 实体数据集合[DEFAULT]标识
     */
    public final static String DATASET_DEFAULT = "DEFAULT";


    public ProjectMembersService () {
        super();

    }

    /**
     * 获取实体[ProjectMembers]服务对象
     * @param sessionFactory
     * @return
     * @throws Exception
     */
    public static ProjectMembersService getInstance() throws Exception {
        return getInstance(null);
    }

    /**
     * 获取实体[ProjectMembers]服务对象
     * @param sessionFactory
     * @return
     * @throws Exception
     */
    public static ProjectMembersService getInstance(SessionFactory sessionFactory) throws Exception {
        return (ProjectMembersService)ServiceGlobal.getService(ProjectMembersService.class, sessionFactory);
    }

    /**
     * Spring注册后执行构造处理
     * @throws Exception
     */
    @PostConstruct
    public void postConstruct() throws Exception {
        ServiceGlobal.registerService(getServiceId(), this);
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#getServiceId()
     */
    @Override
    protected String getServiceId() {
        return "com.sa.ibiz.demo.srv.demo.service.ProjectMembersService";
    }

    private ProjectMembersDEModel projectMembersDEModel;
    /**
     * 获取实体[ProjectMembers]模型对象
     */
    public  ProjectMembersDEModel getProjectMembersDEModel() {
        if(this.projectMembersDEModel==null) {
            try {
                this.projectMembersDEModel = (ProjectMembersDEModel)DEModelGlobal.getDEModel("com.sa.ibiz.demo.srv.demo.demodel.ProjectMembersDEModel");
            } catch(Exception ex) {
            }
        }
        return this.projectMembersDEModel;
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#getDEModel()
     */
    @Override
    public  IDataEntityModel getDEModel() {
        return this.getProjectMembersDEModel();
    }


    private ProjectMembersDAO projectMembersDAO;

    /**
     * 获取实体[ProjectMembers]数据操作对象
     */
    public  ProjectMembersDAO getProjectMembersDAO() {
        if(this.projectMembersDAO==null) {
            try {
                this.projectMembersDAO= (ProjectMembersDAO)DAOGlobal.getDAO("com.sa.ibiz.demo.srv.demo.dao.ProjectMembersDAO",this.getSessionFactory());
            } catch(Exception ex) {
            }
        }
        return this.projectMembersDAO;
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.IService#getDAO()
     */
    @Override
    public  IDAO getDAO() {
        return this.getProjectMembersDAO();
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onfetchDataSet(java.lang.String, net.ibizsys.paas.core.IDEDataSetFetchContext)
     */
    @Override
    protected DBFetchResult onfetchDataSet(String strDataSetName,IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception {
        if(StringHelper.compare(strDataSetName,DATASET_DEFAULT,true)==0) {
            return this.fetchDefault(iDEDataSetFetchContext);
        }
        return super.onfetchDataSet(strDataSetName,iDEDataSetFetchContext);
    }


    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onExecuteAction(java.lang.String, net.ibizsys.paas.entity.IEntity)
     */
    @Override
    protected  void onExecuteAction(String strAction,IEntity entity) throws Exception {
        super.onExecuteAction(strAction,entity);
    }

    /**
     * 获取数据集合[DEFAULT]
     * @param iDEDataSetFetchContext
     * @return
     * @throws Exception
     */
    public DBFetchResult fetchDefault(IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception {

        DBFetchResult dbFetchResult =  doServiceFetchWork(iDEDataSetFetchContext,DATASET_DEFAULT,false);
        // dbFetchResult.getDataSet().cacheDataRow();
        // session.close();
        return dbFetchResult;
    }







    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onFillParentInfo(net.ibizsys.paas.entity.IEntity, java.lang.String, java.lang.String, java.lang.String)
     */
    @Override
    protected void onFillParentInfo(ProjectMembers et,String strParentType,String strTypeParam,String strParentKey) throws Exception {
        //关系类型 : DER1N ,主实体 :PROJECT / 项目
        if (((StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_DER1N, true) == 0)
                ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_SYSDER1N, true) == 0)
                ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_DER11, true) == 0)
                ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_SYSDER11, true) == 0))
                && (StringHelper.compare(strTypeParam, "DER1N_PROJECTMEMBERS_PROJECT_PROJECTID", true)==0)) {
            IService iService= ServiceGlobal.getService("com.sa.ibiz.demo.srv.demo.service.ProjectService",this.getSessionFactory());
            com.sa.ibiz.demo.srv.demo.entity.Project parentEntity = ( com.sa.ibiz.demo.srv.demo.entity.Project)iService.getDEModel().createEntity();
            parentEntity.set(com.sa.ibiz.demo.srv.demo.entity.Project.FIELD_PROJECTID,DataTypeHelper.parse(25,strParentKey));
            if(strParentKey.indexOf(ServiceBase.TEMPKEY) == 0)
                iService.getTemp(parentEntity);
            else
                iService.get(parentEntity);
            this.onFillParentInfo_PROJECT(et,parentEntity );
            return;
        }
        //关系类型 : DER1N ,主实体 :EMPLOYEE / 职工
        if (((StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_DER1N, true) == 0)
                ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_SYSDER1N, true) == 0)
                ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_DER11, true) == 0)
                ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_SYSDER11, true) == 0))
                && (StringHelper.compare(strTypeParam, "DER1N_PROJECTMEMBERS_EMPLOYEE_EMPLOYEEID", true)==0)) {
            IService iService= ServiceGlobal.getService("com.sa.ibiz.demo.srv.demo.service.EmployeeService",this.getSessionFactory());
            com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity = ( com.sa.ibiz.demo.srv.demo.entity.Employee)iService.getDEModel().createEntity();
            parentEntity.set(com.sa.ibiz.demo.srv.demo.entity.Employee.FIELD_EMPLOYEEID,DataTypeHelper.parse(25,strParentKey));
            if(strParentKey.indexOf(ServiceBase.TEMPKEY) == 0)
                iService.getTemp(parentEntity);
            else
                iService.get(parentEntity);
            this.onFillParentInfo_EMPLOYEE(et,parentEntity );
            return;
        }
        super.onFillParentInfo(et,strParentType,strTypeParam,strParentKey);
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onSyncDER1NData(java.lang.String, java.lang.String, java.lang.String)
     */
    @Override
    protected String onSyncDER1NData(String strDER1NId, String strParentKey, String strDatas) throws Exception {
        return super.onSyncDER1NData( strDER1NId,  strParentKey,  strDatas);
    }


    /**
    * 填充数据的父数据信息[项目]
    * @param et 当前数据对象
    * @param parentEntity 父数据对象
    * @throws Exception
    */
    protected void onFillParentInfo_PROJECT(ProjectMembers et,com.sa.ibiz.demo.srv.demo.entity.Project parentEntity) throws Exception {
        et.setProjectId(parentEntity.getProjectId());
        et.setProjectName(parentEntity.getProjectName());
    }

    /**
    * 填充数据的父数据信息[职工]
    * @param et 当前数据对象
    * @param parentEntity 父数据对象
    * @throws Exception
    */
    protected void onFillParentInfo_EMPLOYEE(ProjectMembers et,com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity) throws Exception {
        et.setEmployeeId(parentEntity.getEmployeeId());
        et.setEmployeeName(parentEntity.getEmployeeName());
    }




    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onFillEntityFullInfo(net.ibizsys.paas.entity.IEntity, boolean)
     */
    @Override
    protected void onFillEntityFullInfo(ProjectMembers et, boolean bCreate) throws Exception {
        //填充新建默认值
        if(bCreate) {
        }
        super.onFillEntityFullInfo(et, bCreate);

        //填充物理化外键相关属性
        //关系类型 : DER1N ,主实体 :PROJECT / 项目
        onFillEntityFullInfo_PROJECT(et, bCreate);
        //关系类型 : DER1N ,主实体 :EMPLOYEE / 职工
        onFillEntityFullInfo_EMPLOYEE(et, bCreate);
    }

    /**
    * 填充实体的数据信息 项目
    * @param et
    * @param bCreate 是否建立
    * @throws Exception
    */
    protected void onFillEntityFullInfo_PROJECT(ProjectMembers et, boolean bCreate) throws Exception {
    }
    /**
    * 填充实体的数据信息 职工
    * @param et
    * @param bCreate 是否建立
    * @throws Exception
    */
    protected void onFillEntityFullInfo_EMPLOYEE(ProjectMembers et, boolean bCreate) throws Exception {
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onWriteBackParent(net.ibizsys.paas.entity.IEntity, boolean)
     */
    @Override
    protected void onWriteBackParent(ProjectMembers et, boolean bCreate) throws Exception {
        super.onWriteBackParent(et, bCreate);
    }




    /**
     * 通过关系[项目]父数据查询数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public java.util.ArrayList<ProjectMembers> selectByPROJECT(com.sa.ibiz.demo.srv.demo.entity.Project parentEntity) throws Exception {
        return selectByPROJECT(parentEntity,"");
    }
    /**
     * 通过关系[项目]父数据查询数据
     * @param parentEntity 父数据
     * @param strOrderInfo 排序信息
     * @throws Exception
     */
    public java.util.ArrayList<ProjectMembers> selectByPROJECT(com.sa.ibiz.demo.srv.demo.entity.Project parentEntity,String strOrderInfo) throws Exception {
        SelectCond selectCond = new SelectCond();
        selectCond.setConditon(ProjectMembers.FIELD_PROJECTID, parentEntity.getProjectId());
        selectCond.setOrderInfo(strOrderInfo);
        onFillSelectByPROJECTCond(selectCond);
        return this.select(selectCond);
    }

    /**
     * 填充关系[项目]父数据查询附加条件
     * @param selectCond 查询条件对象
     * @throws Exception
     */
    protected void onFillSelectByPROJECTCond(SelectCond selectCond) throws Exception {

    }

    /**
     * 通过关系[职工]父数据查询数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public java.util.ArrayList<ProjectMembers> selectByEMPLOYEE(com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity) throws Exception {
        return selectByEMPLOYEE(parentEntity,"");
    }
    /**
     * 通过关系[职工]父数据查询数据
     * @param parentEntity 父数据
     * @param strOrderInfo 排序信息
     * @throws Exception
     */
    public java.util.ArrayList<ProjectMembers> selectByEMPLOYEE(com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity,String strOrderInfo) throws Exception {
        SelectCond selectCond = new SelectCond();
        selectCond.setConditon(ProjectMembers.FIELD_EMPLOYEEID, parentEntity.getEmployeeId());
        selectCond.setOrderInfo(strOrderInfo);
        onFillSelectByEMPLOYEECond(selectCond);
        return this.select(selectCond);
    }

    /**
     * 填充关系[职工]父数据查询附加条件
     * @param selectCond 查询条件对象
     * @throws Exception
     */
    protected void onFillSelectByEMPLOYEECond(SelectCond selectCond) throws Exception {

    }




    /**
     * 判断是否能够通过关系[项目]删除数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void testRemoveByPROJECT(com.sa.ibiz.demo.srv.demo.entity.Project parentEntity) throws Exception {
    }


    /**
     * 通过关系[项目]重置数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void resetPROJECT(com.sa.ibiz.demo.srv.demo.entity.Project parentEntity) throws Exception {
        java.util.ArrayList<ProjectMembers> list =  this.selectByPROJECT(parentEntity);
        for(ProjectMembers item:list) {
            ProjectMembers item2 = (ProjectMembers)getDEModel().createEntity();
            item2.setProjectMembersId(item.getProjectMembersId());
            item2.setProjectId(null);
            this.update(item2);
        }
    }


    /**
     * 通过关系[项目]删除数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void removeByPROJECT(com.sa.ibiz.demo.srv.demo.entity.Project parentEntity) throws Exception {
        final com.sa.ibiz.demo.srv.demo.entity.Project parentEntity2 = parentEntity;
        this.doServiceWork(new IServiceWork() {
            @Override
            public void execute(ITransaction iTransaction) throws Exception {
                onBeforeRemoveByPROJECT(parentEntity2);
                internalRemoveByPROJECT(parentEntity2);
                onAfterRemoveByPROJECT(parentEntity2);
            }
        });
    }

    /**
     * 通过关系[项目]删除数据之前调用
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void onBeforeRemoveByPROJECT(com.sa.ibiz.demo.srv.demo.entity.Project parentEntity) throws Exception {

    }

    /**
    * 内部删除数据，通过关系[项目]
    * @param parentEntity 父数据
    * @throws Exception
    */
    protected void internalRemoveByPROJECT(com.sa.ibiz.demo.srv.demo.entity.Project parentEntity) throws Exception {
        java.util.ArrayList<ProjectMembers> removeList = selectByPROJECT(parentEntity);
        onBeforeRemoveByPROJECT(parentEntity,removeList );

        // 执行删除
        for (ProjectMembers item : removeList ) {
            remove(item );
        }
        onAfterRemoveByPROJECT(parentEntity,removeList );
    }

    /**
     * 通过关系[项目]删除数据之后调用
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void onAfterRemoveByPROJECT(com.sa.ibiz.demo.srv.demo.entity.Project parentEntity) throws Exception {

    }

    /**
     * 通过关系[项目]删除数据之前调用
     * @param parentEntity 父数据
     * @param removeList 要删除的数据清单
     * @throws Exception
     */
    protected void onBeforeRemoveByPROJECT(com.sa.ibiz.demo.srv.demo.entity.Project parentEntity,java.util.ArrayList<ProjectMembers> removeList) throws Exception {

    }

    /**
     * 通过关系[项目]删除数据之后调用
     * @param parentEntity 父数据
     * @param removeList 要删除的数据清单
     * @throws Exception
     */
    protected void onAfterRemoveByPROJECT(com.sa.ibiz.demo.srv.demo.entity.Project parentEntity,java.util.ArrayList<ProjectMembers> removeList) throws Exception {

    }

    /**
     * 判断是否能够通过关系[职工]删除数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void testRemoveByEMPLOYEE(com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity) throws Exception {
    }


    /**
     * 通过关系[职工]重置数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void resetEMPLOYEE(com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity) throws Exception {
        java.util.ArrayList<ProjectMembers> list =  this.selectByEMPLOYEE(parentEntity);
        for(ProjectMembers item:list) {
            ProjectMembers item2 = (ProjectMembers)getDEModel().createEntity();
            item2.setProjectMembersId(item.getProjectMembersId());
            item2.setEmployeeId(null);
            this.update(item2);
        }
    }


    /**
     * 通过关系[职工]删除数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void removeByEMPLOYEE(com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity) throws Exception {
        final com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity2 = parentEntity;
        this.doServiceWork(new IServiceWork() {
            @Override
            public void execute(ITransaction iTransaction) throws Exception {
                onBeforeRemoveByEMPLOYEE(parentEntity2);
                internalRemoveByEMPLOYEE(parentEntity2);
                onAfterRemoveByEMPLOYEE(parentEntity2);
            }
        });
    }

    /**
     * 通过关系[职工]删除数据之前调用
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void onBeforeRemoveByEMPLOYEE(com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity) throws Exception {

    }

    /**
    * 内部删除数据，通过关系[职工]
    * @param parentEntity 父数据
    * @throws Exception
    */
    protected void internalRemoveByEMPLOYEE(com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity) throws Exception {
        java.util.ArrayList<ProjectMembers> removeList = selectByEMPLOYEE(parentEntity);
        onBeforeRemoveByEMPLOYEE(parentEntity,removeList );

        // 执行删除
        for (ProjectMembers item : removeList ) {
            remove(item );
        }
        onAfterRemoveByEMPLOYEE(parentEntity,removeList );
    }

    /**
     * 通过关系[职工]删除数据之后调用
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void onAfterRemoveByEMPLOYEE(com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity) throws Exception {

    }

    /**
     * 通过关系[职工]删除数据之前调用
     * @param parentEntity 父数据
     * @param removeList 要删除的数据清单
     * @throws Exception
     */
    protected void onBeforeRemoveByEMPLOYEE(com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity,java.util.ArrayList<ProjectMembers> removeList) throws Exception {

    }

    /**
     * 通过关系[职工]删除数据之后调用
     * @param parentEntity 父数据
     * @param removeList 要删除的数据清单
     * @throws Exception
     */
    protected void onAfterRemoveByEMPLOYEE(com.sa.ibiz.demo.srv.demo.entity.Employee parentEntity,java.util.ArrayList<ProjectMembers> removeList) throws Exception {

    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onBeforeRemove(net.ibizsys.paas.entity.IEntity)
     */
    @Override
    protected void onBeforeRemove(ProjectMembers et) throws Exception {
        super.onBeforeRemove(et);
    }





    /**
     * 替换父数据信息
     * @param et
     * @throws Exception
     */
    @Override
    protected void replaceParentInfo(ProjectMembers et,CloneSession cloneSession) throws Exception {
        super.replaceParentInfo(et, cloneSession);
        //循环所有的从关系，判断有误替换
        if(et.getProjectId()!=null) {
            IEntity entity = cloneSession.getEntity("PROJECT",et.getProjectId());
            if(entity !=null) {
                onFillParentInfo_PROJECT(et,(com.sa.ibiz.demo.srv.demo.entity.Project) entity);
            }
        }
        if(et.getEmployeeId()!=null) {
            IEntity entity = cloneSession.getEntity("EMPLOYEE",et.getEmployeeId());
            if(entity !=null) {
                onFillParentInfo_EMPLOYEE(et,(com.sa.ibiz.demo.srv.demo.entity.Employee) entity);
            }
        }
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onRemoveEntityUncopyValues(net.ibizsys.paas.entity.IEntity, boolean)
     */
    @Override
    protected void onRemoveEntityUncopyValues(ProjectMembers et, boolean bTempMode) throws Exception {
        super.onRemoveEntityUncopyValues(et,  bTempMode);
    }


    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onCheckEntity(boolean, net.ibizsys.paas.entity.IEntity, boolean, boolean, net.ibizsys.paas.entity.EntityError)
     */
    @Override
    protected void onCheckEntity(boolean bBaseMode,ProjectMembers  et, boolean bCreate, boolean bTempMode,EntityError entityError) throws Exception {
        EntityFieldError entityFieldError = null;
        //检查属性 职工标识
        entityFieldError = onCheckField_EmployeeId( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 项目标识
        entityFieldError = onCheckField_ProjectId( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 项目成员（关系实体）标识
        entityFieldError = onCheckField_ProjectMembersId( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 项目成员（关系实体）名称
        entityFieldError = onCheckField_ProjectMembersName( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        super.onCheckEntity(bBaseMode,et,  bCreate,bTempMode,entityError);
    }


    /**
     * 获取属性[EmployeeId]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_EmployeeId(boolean bBaseMode,ProjectMembers et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isEmployeeIdDirty())
            return null;

        String value = et.getEmployeeId();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_EmployeeId_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(ProjectMembers.FIELD_EMPLOYEEID);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[ProjectId]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_ProjectId(boolean bBaseMode,ProjectMembers et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isProjectIdDirty())
            return null;

        String value = et.getProjectId();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_ProjectId_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(ProjectMembers.FIELD_PROJECTID);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[ProjectMembersId]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_ProjectMembersId(boolean bBaseMode,ProjectMembers et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isProjectMembersIdDirty())
            return null;

        String value = et.getProjectMembersId();
        if(bBaseMode) {
            if(bCreate) {
                if(StringHelper.isNullOrEmpty(value)) {
                    EntityFieldError entityFieldError = new EntityFieldError();
                    entityFieldError.setFieldName(ProjectMembers.FIELD_PROJECTMEMBERSID);
                    entityFieldError.setErrorType(EntityFieldError.ERROR_EMPTY);
                    return entityFieldError;
                }
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_ProjectMembersId_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(ProjectMembers.FIELD_PROJECTMEMBERSID);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[ProjectMembersName]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_ProjectMembersName(boolean bBaseMode,ProjectMembers et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isProjectMembersNameDirty())
            return null;

        String value = et.getProjectMembersName();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_ProjectMembersName_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(ProjectMembers.FIELD_PROJECTMEMBERSNAME);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }




    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onSyncEntity(net.ibizsys.paas.entity.IEntity, boolean)
     */
    @Override
    protected void onSyncEntity(ProjectMembers et, boolean bRemove) throws Exception {
        super.onSyncEntity( et,  bRemove);
    }


    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onSyncIndexEntities(net.ibizsys.paas.entity.IEntity, boolean)
     */
    @Override
    protected void onSyncIndexEntities(ProjectMembers et,boolean bRemove) throws Exception {
        super.onSyncIndexEntities(et,bRemove);
    }


    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#getDataContextValue(net.ibizsys.paas.entity.IEntity, java.lang.String, net.ibizsys.paas.service.IDataContextParam)
     */
    @Override
    public Object getDataContextValue(ProjectMembers et,String strField,IDataContextParam iDataContextParam)throws Exception {
        Object objValue = null;
        if(iDataContextParam!=null) {
        }

        objValue = super.getDataContextValue(et,strField,iDataContextParam);
        if(objValue!=null)
            return objValue;

        IEntity pROJECT =et.getPROJECT();
        if(pROJECT!=null) {
            if(pROJECT.contains(strField)) {
                return pROJECT.get(strField);
            }
        }
        IEntity eMPLOYEE =et.getEMPLOYEE();
        if(eMPLOYEE!=null) {
            if(eMPLOYEE.contains(strField)) {
                return eMPLOYEE.get(strField);
            }
        }
        return null;
    }



    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onTestValueRule(java.lang.String, java.lang.String, net.ibizsys.paas.entity.IEntity, boolean, boolean)
     */
    @Override
    protected String onTestValueRule(String strDEFieldName,String strRule,IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        if((StringHelper.compare(strDEFieldName,ProjectMembers.FIELD_PROJECTMEMBERSNAME,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_ProjectMembersName_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,ProjectMembers.FIELD_UPDATEDATE,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_UpdateDate_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,ProjectMembers.FIELD_CREATEMAN,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_CreateMan_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,ProjectMembers.FIELD_PROJECTMEMBERSID,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_ProjectMembersId_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,ProjectMembers.FIELD_UPDATEMAN,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_UpdateMan_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,ProjectMembers.FIELD_CREATEDATE,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_CreateDate_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,ProjectMembers.FIELD_PROJECTNAME,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_ProjectName_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,ProjectMembers.FIELD_EMPLOYEENAME,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_EmployeeName_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,ProjectMembers.FIELD_EMPLOYEEID,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_EmployeeId_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,ProjectMembers.FIELD_PROJECTID,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_ProjectId_Default(et,bCreate,bTempMode);

        return super.onTestValueRule( strDEFieldName, strRule, et,bCreate, bTempMode);
    }

    /**
     * 判断值规则[项目成员（关系实体）名称][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_ProjectMembersName_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("PROJECTMEMBERSNAME", et, bTempMode,null,false,200,true,"内容长度必须小于等于[200]")))
                return null;
            return "内容长度必须小于等于[200]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[更新时间][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_UpdateDate_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        return null;
    }

    /**
     * 判断值规则[建立人][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_CreateMan_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("CREATEMAN", et, bTempMode,null,false,60,true,"内容长度必须小于等于[60]")))
                return null;
            return "内容长度必须小于等于[60]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[项目成员（关系实体）标识][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_ProjectMembersId_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("PROJECTMEMBERSID", et, bTempMode,null,false,100,true,"内容长度必须小于等于[100]")))
                return null;
            return "内容长度必须小于等于[100]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[更新人][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_UpdateMan_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("UPDATEMAN", et, bTempMode,null,false,60,true,"内容长度必须小于等于[60]")))
                return null;
            return "内容长度必须小于等于[60]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[建立时间][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_CreateDate_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        return null;
    }

    /**
     * 判断值规则[项目名称][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_ProjectName_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("PROJECTNAME", et, bTempMode,null,false,200,true,"内容长度必须小于等于[200]")))
                return null;
            return "内容长度必须小于等于[200]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[职工名称][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_EmployeeName_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("EMPLOYEENAME", et, bTempMode,null,false,200,true,"内容长度必须小于等于[200]")))
                return null;
            return "内容长度必须小于等于[200]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[职工标识][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_EmployeeId_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("EMPLOYEEID", et, bTempMode,null,false,100,true,"内容长度必须小于等于[100]")))
                return null;
            return "内容长度必须小于等于[100]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[项目标识][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_ProjectId_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("PROJECTID", et, bTempMode,null,false,100,true,"内容长度必须小于等于[100]")))
                return null;
            return "内容长度必须小于等于[100]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }



    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onMergeChild(java.lang.String, java.lang.String, net.ibizsys.paas.entity.IEntity)
     */
    @Override
    protected boolean onMergeChild(String strChildType, String strTypeParam, ProjectMembers et) throws Exception {
        boolean bRet = false;
        if(super.onMergeChild( strChildType, strTypeParam,  et))
            bRet = true;
        return bRet;
    }



    /**
     * 更新父数据
     * @param et
     * @throws Exception
     */
    @Override
    protected void onUpdateParent(ProjectMembers et)throws Exception {
        super.onUpdateParent(et);
    }


}